<template>
  <div>
    <div
      class="list-expenditure"
    >
      <div class="img">
        <Avatar
          :src="teamList.UserImg"
          class="class-img"
        />
      </div>
      <div class="list-content">
        <div class="title">
          {{ teamList.UserName ? teamList.UserName : teamList.UserPhone }}
        </div>
        <div class="team-num">
          他的团队: <span>{{ teamList.TeamPeople }}</span>人
        </div>
        <div class="team-remarks">
          备注：{{ remarks ? remarks : '无' }}
        </div>
        <div class="num">
          {{ teamList.JoinTeam }}
        </div>
      </div>
      <div class="list-r">
        <div
          class="list-r-p"
        >
          分销订单数:
          <span class="order-num">
            {{ teamList.DistributionOrders }}
          </span>
        </div>
        <div class="team-btn">
          <img
            src="~assets/scholarship/remarks.png"
            class="class-img"
            @click="showRemark"
          >
          <a
            :href="teamList.UserPhone ? 'tel://' + teamList.UserPhone : 'javascript:void(0)'"
          >
            <img
              src="~assets/scholarship/tel.png"
              class="class-img"
            >
          </a>
        </div>
      </div>
    </div>

    <van-popup
      v-model="show"
      class="remark-popup"
    >
      <div class="remark">
        <div class="title">
          备注
        </div>
        <textarea
          v-model="remarks"
          rows="6"
          placeholder="最多可输入200个字符"
          maxlength="200"
          @blur="onIosBlur"
        />
        <div class="bottom">
          <van-button
            size="small"
            type="primary"
            class="btn btn-cancel"
            @click="cancel"
          >
            取消
          </van-button>
          <van-button
            size="small"
            type="primary"
            class="btn btn-save"
            @click="saveRemark"
          >
            保存
          </van-button>
        </div>
      </div>
    </van-popup>
  </div>
</template>

<script lang="ts">

import Vue from 'vue'
import { isiOS } from '@/lib/utils'
export default Vue.extend({
  components: {
    Avatar: () => import(/* webpackChunkName: "publicComp" */'components/Mine/Avatar.vue'),
  },
  // eslint-disable-next-line vue/require-default-prop
  // eslint-disable-next-line vue/require-prop-types
  props: ['teamList'],
  data () {
    return {
      show: false,
      remarks: this.teamList.Remarks,
    }
  },
  methods: {
    onIosBlur () {
      if (isiOS) {
        console.log('9999999933')
        document.body.scrollTop = document.documentElement!.scrollTop = 0
      }
    },
    // 点击备注按钮
    showRemark () {
      // this.$emit('showRemark')
      this.show = true
    },
    // 点击取消按钮
    cancel () {
      this.show = false
      this.remarks = this.teamList.Remarks
    },
    // 点击保存按钮提交备注
    saveRemark () {
      this.$axios({
        url: 'User/SubmitTeamMembersRemarks',
        data: {
          TeamUserId: this.teamList.UserId,
          Remarks: this.remarks,
        },
      }).then(res => {
        this.show = false
        this.$emit('updateRemarks', this.remarks)
      })
    },
  },
})
</script>
<style  lang="scss" scoped>
.van-list {
  .list-expenditure {
    display: flex;
    width: 100%;
    .img{
      padding-right: 30px;
      display: flex;
      align-items: center;
      img{
        width: 120px;
      }
    }
    .list-r{
      width: 35%;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      text-align: right;
      img{
        width: 73px;
      }
    }
  }
}
.list-content {
  vertical-align: middle;
  width: calc(55% - 30px);
  .team-num {
    color: #666666;
    font-size: 24px;
    margin-bottom: 26px;
  }
  .team-remarks {
    font-size: 22px;
    color: #999;
    margin-bottom: 20px;
    @include ellipsis;
  }
  .title {
    color: #333333;
    font-size: 32px;
    margin-bottom: 16px;
  }
  .num {
    color: #999;
    font-size: 22px;
    margin-bottom: 30px;
  }
}
.list-r-p{
  color: #666;
  font-size: 24px;
  margin-right: 15px;
  margin-top: 4px;
}
.order-num {
  color: #333;
}
.team-btn {
  margin-bottom: 18px;
}
.remark-popup{
  width: 640px;
  padding: 30px 30px 40px;
  border-radius:3px;
  .remark{
    .title{
      color: #333;
      font-size:36px;
      margin-bottom: 30px;
      text-align: center;
    }
    textarea{
      width: 100%;
      border: 1px solid #e9e9e9;
      font-size: 24px;
      height: 300px;
      padding: 20px;
    }
    .bottom{
      margin-top: 40px;
      display: flex;
      justify-content:space-between;
    }
    .btn{
      width: 266px;
      height: 70px;
      font-size: 36px;
      @include px1border(all, $primary-web)
    }
    .btn-cancel{
      background-color: #fff;
      color: $primary-web;
    }
  }
}
</style>
